package uestc.lj.gulishop.product.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import uestc.lj.gulishop.product.service.SkuInfoService;
import uestc.lj.gulishop.product.vo.SkuItemVO;

import java.util.concurrent.ExecutionException;

@Controller
public class ItemController {
    @Autowired
    private SkuInfoService skuInfoService;

    /**
     * 根据skuid查询商品详情
     *
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {

        SkuItemVO skuItemVO = skuInfoService.getSkuItem(skuId);
        model.addAttribute("item", skuItemVO);
        return "item";
    }
}
